//
//  ViewController+tabbar.swift
//  WZApp
//
//  Created by evol on 2018/7/9.
//  Copyright © 2018年 evol. All rights reserved.
//

import UIKit

extension ViewController {
    func setTabbar() -> Void {
        // 底部分类
        let viewModel = ELTabbarViewModel()
        tabbar = ELTabbarTool(viewModel)
        self.view.addSubview(tabbar)
        tabbar.snp.makeConstraints {
            $0.left.right.bottom.equalTo(self.view)
        }
        
        viewModel.cancelCommand.subscribe(onNext:{
            [weak self] (index) in
            self?.scrollView.viewModel.tabbarResponse.onNext(.cancel)
        }).disposed(by:disposeBag)
        viewModel.selectCommand.subscribe(onNext:{
            [weak self] (index) in
            self?.scrollView.viewModel.tabbarResponse.onNext(.fistLevel(id:index))
        }).disposed(by: disposeBag)
        viewModel.selectSubCommand.subscribe(onNext:{
            [weak self] (index) in
            self?.scrollView.viewModel.tabbarResponse.onNext(.sencondLevel(id:index))
        }).disposed(by: disposeBag)
    }
}
